
#pragma once

#include <ttg/services.h>

#include "TempFile.h"
#include "FileLoader.h"
#include "HashFunction.h"

//Performs serial file hashing and returns hash-value + elapsed time.
std::pair<unsigned __int64, double> serialHashing(TempFile &file)
{
	//Preparing.
	FileLoader loader(file.getFileName());
	Buffer<char> *b;
	unsigned __int64 res = 0;
	//Performing.
	double t_start = ttg::services::ServiceBase::_Timer().getSeconds();
	while ((b = loader.loadNext()) != NULL)
	{
		res += hashFunc(b);
		delete b;
	}
	double t_end = ttg::services::ServiceBase::_Timer().getSeconds();
	//Returning result.
	return std::pair<unsigned __int64, double>(res, t_end - t_start);
}
